package com.zhss.ddd.lottery.draw.activity.service;

import com.zhss.ddd.lottery.draw.activity.api.ILotteryDrawActivity;
import com.zhss.ddd.lottery.draw.activity.api.LotteryDrawActivityApi;
import com.zhss.ddd.lottery.draw.activity.entity.CandidateGroup;
import com.zhss.ddd.lottery.draw.activity.entity.LotteryDrawActivity;
import com.zhss.ddd.lottery.draw.activity.entity.Prize;
import com.zhss.ddd.lottery.draw.activity.spring.SpringContext;
import com.zhss.ddd.lottery.draw.activity.vo.DrawLotteryContext;
import lombok.Data;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 抽奖活动
 */
@Service(
        version = "1.0.0",
        interfaceClass = ILotteryDrawActivity.class,
        cluster = "failfast",
        loadbalance = "roundrobin"
)
@Data
public class LotteryDrawActivityService implements LotteryDrawActivityApi {

    @Autowired
    private SpringContext springContext;

    /**
     * 获取抽奖活动数据
     * @param lotteryDrawActivityId 抽奖活动id
     */
    @Override
    public DrawLotteryContext getContext(Long lotteryDrawActivityId) {
        // 还原出实体
        LotteryDrawActivity lotteryDrawActivity = springContext.getBean(LotteryDrawActivity.class);
        lotteryDrawActivity.setId(lotteryDrawActivityId);
        return lotteryDrawActivity.getContext();
    }

}
